<!DOCTYPE html>
<html lang="en">
<head>
    <title>个人进拜访列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>

    <style>
        [v-cloak] {
            display: none;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            font-size: 12px;
        }

        body {
            margin: 1px;
            background: #f8f8f8;
        }

        table {
            border-spacing: 0;
            border-collapse: collapse;
            display: table;
        }

        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: 12px;
        }

        .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #cbcbcd;
            font-weight: normal;
            height: 24px;
        }

        .table th {
            background: yellow;
        }

        .table-bordered {
            border: 1px solid #cbcbcd;
        }

        .table {
            width: 100%;
            max-width: 100%;
        }

        .hidden {
            display: none;
        }

        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 24px;
            line-height: 24px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .mScrollBox {
            float: left;
            position: relative;
            overflow: hidden;
        }

        .infoReport {
            text-align: center;
            margin: 0;
            margin-bottom: 10px;
        }

        .moduleName {
            height: 20px;
            line-height: 20px;
            background: #f8f8f8;
            font-weight: bold;
            font-size: 14px;
        }

        .oaReportNav {
            position: relative;
        }

        .toggleDiv {
            height: 20px;
            line-height: 20px;
            margin-bottom: 10px;
        }

        .toggleDiv div {
            width: 50%;
            float: left;
            text-align: center;
        }

        .toggleDiv div.active {
            border-bottom: 2px solid #2289ee;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
    </style>
</head>
<body>
<section class="content" id="app" v-cloak>
    <div class="div-td-content-more"><i></i></div>

    <template v-if="isQuYuJinLi">
        <div style="padding:10px 0;background: #fff;overflow: hidden;" id="interviewCompany">
            <div style="width: 100%;" class="mScrollBox">
                <table class="table table-bordered text-center table-width">
                    <thead>
                    <tr>
                        <!--<th style="width: 8%;">序号</th>-->
                        <th style="width: 15%;">面访排名
                        </th>
                        <!--<th style="width:85px" v-if="visitCustomer.time!=today">日均完成</th>-->
                        <th style="width: 10%;">完成
                        </th>
                        <th style="width: 10%;">目标</th>
                        <th style="width: 20%;">区域经理</th>
                        <!--<th style="width:85px" v-if="visitCustomer.time!=today">出勤天数</th>-->
                        <th style="width: 45%;">区域</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for="(item,i) in visitCustomer.faceList">
                        <!--<td>{{i+1}}</td>-->
                        <td>{{item.rownum}}</td>
                        <!--<td v-if="visitCustomer.time!=today">{{item.averageComplete}}</td>-->
                        <td v-if="userId==item.userId&&item.complete!='-'" style="color:#169BD5;cursor: pointer" @click="lookInterview2(item,'1')">
                            {{item.complete}}
                        </td>
                        <td v-else>{{item.complete}}</td>
                        <td>
                            {{item.target}}
                        </td>

                        <td>{{item.userName}}</td>
                        <!--<td v-if="visitCustomer.time!=today">{{item.signManagerNum}}</td>-->
                        <td class="lineOne"><span>{{item.regionName}}</span></td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div style="width: 100%;float:right;margin-top: 10px;" class="mScrollBox">
                <table class="table table-bordered text-center table-width">
                    <thead>
                    <tr>
                        <!--<th style="width: 8%;">序号</th>-->
                        <th style="width: 15%;">电访排名
                        </th>
                        <!--<th style="width:85px" v-if="visitCustomer.time!=today">日均完成</th>-->
                        <th style="width: 10%;">完成
                        </th>
                        <th style="width: 10%;">目标</th>
                        <th style="width: 20%;">区域经理</th>
                        <!--<th style="width:85px" v-if="visitCustomer.time!=today">出勤天数</th>-->
                        <th style="width: 45%;">区域</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for="(item,i) in visitCustomer.telList">
                        <!--<td>{{i+1}}</td>-->
                        <td>{{item.rownum}}</td>
                        <!--<td v-if="visitCustomer.time!=today">{{item.averageComplete}}</td>-->
                        <td v-if="userId==item.userId&&item.complete!='-'" style="color:#169BD5;cursor: pointer" @click="lookInterview2(item,'0')">
                            {{item.complete}}
                        </td>
                        <td v-else>{{item.complete}}</td>
                        <td>
                            {{item.target}}
                        </td>
                        <td>{{item.userName}}</td>
                        <!--<td v-if="visitCustomer.time!=today">{{item.signManagerNum}}</td>-->
                        <td class="lineOne"><span>{{item.regionName}}</span></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </template>
    <template v-else>
        <div style="text-align: center;font-size: x-small;margin: 6px 0">
            <template v-if="visitType==1">面访
                <template v-if="hour<8 && isDay"><br/>(昨日)</template>
            </template>
            <template v-else>
                电访
                <template v-if="isDay"><br/>(昨日)</template>
            </template>
            :目标（{{visitType == 1? sendData.faceTargetInfo.dayTarget:
            sendData.telTargeInfo.dayTarget}}），完成（{{visitType == 1?
            sendData.faceTargetInfo.complete:sendData.telTargeInfo.complete}}）
        </div>
        <table class="table table-hover table-bordered text-center ">
            <thead>
            <tr>
                <th style="width:20%;">客户电话</th>
                <th style="width:20%;">客户姓名</th>
                <th style="width:20%;">客户<br/>微信号</th>
                <th style="width:20%;">拜访日期</th>
                <th v-if="visitType == 1" style="width: 20%;">拜访时长</th>
            </tr>
            </thead>
            <tbody>
            <template v-if="visitType==1">
                <tr v-for="(item,i) in sendData.faceTargetDay">
                    <td>{{item.tel}}</td>
                    <td style="color:#2a8cec;cursor: pointer" @click="lookInterview(item,'day')">
                        {{item.name}}
                    </td>
                    <td>{{item.wechat==""?"-":item.wechat}}</td>
                    <td>{{item.date}}</td>
                    <template v-if="visitType == 1">
                        <td v-if="item.time!=0">{{item.time}}分</td>
                        <td v-else>
                            {{item.arrivalsTime?item.arrivalsTime:"-"}}/{{item.leaveTime?item.leaveTime:"-"}}
                        </td>
                    </template>
                </tr>
            </template>
            <template v-else>
                <tr v-for="(item,i) in sendData.telTargetDay">
                    <td>{{item.tel}}</td>
                    <td>
                        {{item.name}}
                    </td>
                    <td>{{item.wechat==""?"-":item.wechat}}</td>
                    <td>{{item.date}}</td>
                    <td v-if="visitType == 1">{{item.arrivalsTime == ""?"-":item.arrivalsTime
                        }}/{{item.leaveTime ==
                        ""?"-":item.leaveTime }}
                    </td>
                </tr>
            </template>
            </tbody>
        </table>
    </template>


    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="/dist/plugins/scroll/myScroll.js"></script>
<!--框架已定义 JS-->
<!--oa自定义  JS-->
<script src="/dist/js/oaApp.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript">
    $(function () {
        $("body").on("click", ".reginTd", function (e) {
            var text = $(this).text();
            if (text != "") {
                text = "<i></i>" + text;
                $(".div-td-content-more").html(text).css({
                    "width": $(this).outerWidth() + "px",
                    "left": $(this).offset().left,
                    "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                }).show();
                e.stopPropagation();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });

</script>
<script>
    $.ajaxSetup({
        global: true,
        type: "POST",
        cache: false,
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        beforeSend: function () {
        },
        complete: function () {

        },
        error: function (e) {
            alert('error' + e.responseText);
        }
    });
    $.extend($.wyui, {
        postMethod: function (url, data, callback, sync, id) {
            if (!id) {
                id = "#app"
            }
            $.ajax({
                url: server.ip + url,
                async: sync ? false : true,
                data: JSON.stringify(data),
                beforeSend: function () {

                },
                complete: function () {
                    setTimeout(function () {
                    }, 1000);

                },
                success: function (r) {
                    if (!r.e.code) {
                        callback(r.data.sendData);
                    } else {
                        alert(r.e.desc);
                    }
                },
                error: function (e) {
                    alert(url + e.responseText);
                }
            });
        },
    });
</script>
<script>
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]);
        return null; //返回参数值
    }

    function isDay(time) {
        //2018-01-01
        if (time.length > 8) {
            return true
        } else {
            return false
        }
    }

    var app = new Vue({
        el: '#app',
        data: {
            userId: getUrlParamObj().userId,
            isDay: isDay(getUrlParamObj().dateTime),
            visitType: getUrlParamObj().type,//0电访 1面访
            sendData: {
                telTargetDay: [],
                faceTargetDay: [],
                faceTargetInfo: {dayTarget: "", complete: ""},
                telTargeInfo: {dayTarget: "", complete: ""}
            },
            hour: new Date().getHours(),
            isQuYuJinLi: false,
            visitCustomer: {
                time: getUrlParamObj().dateTime,
                faceList: [],
                telList: [],
            },
        },
        methods: {
            getUrlParam: function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                if (r != null) return unescape(r[2]);
                return null; //返回参数值
            },
            lookInterview: function (item, type) {
                var that = this;
                var obj = {
                    type: 'lookInterviewDetail',
                    url: '',
                    id: item.id,
                    name: '',
                    dateTime: ''
                }
                prompt(JSON.stringify(obj))
            },
            //区域经理-> 客户列表
            lookInterview2: function (item, type) {
                var that = this;
                var obj = {
                    type: 'customerList',
                    url: '/reportForm/interview/interviewCustomerListApp.html?type=' + type + '&userId=' + item.userId + '&name=' + item.userName + '&dateTime=' + that.visitCustomer.time,
                    id: item.userId,
                    name: item.userName,
                    dateTime: that.visitCustomer.time
                }
                prompt(JSON.stringify(obj))
            },
            getPersonal: function () {
                var that = this
                var data = {
                    userId: getUrlParamObj().userId,
                    dateTime: getUrlParamObj().dateTime,
                    isApp: "1"
                };
                $.ajax({
                    url: server.ip + urlConfig.report.visitCustomer.getPeopleByUserId,
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify(data),
                    success: function (r) {
                        //var res = JSON.parse(r);
                        //console.log(res)
                        that.sendData = r
                    },
                    error: function (e) {
                        alert(e.responseText)
                    }
                })
            },
            //获取拜访报表-区域经理
            get_visitRegion: function () {
                var that = this;
                var param = {
                    "userId": that.userId,
                    "dateTime": that.visitCustomer.time,
                    "type": "1"
                }
                $.wyui.postMethod(urlConfig.report.visitCustomer.getForPersonal, param, function (data) {
                    var data=trimRN2(data);
                    that.visitCustomer.faceList = data;
                }, false, "#visitPersonal");
                $.wyui.postMethod(urlConfig.report.visitCustomer.getForPersonal, {
                    "userId": that.userId,
                    "dateTime": that.visitCustomer.time,
                    "type": "0"
                }, function (data) {
                    var data=trimRN2(data);
                    that.visitCustomer.telList = data;
                }, false, "#visitPersonal");
            },
        },
        mounted: function () {
            var that = this;
            this.visitType = getUrlParamObj().type

            //判断是否是区域经理
            var data = {
                "id": getUrlParamObj().userId,
            }
            $.ajax({
                url: server.ip + urlConfig.system.user.getUserViewById,
                contentType: 'application/json;charset=utf-8',
                type: "POST",
                data: JSON.stringify(data),
                success: function (r) {
                    if (r.data.sendData.roleName == '区域经理') {
                        that.isQuYuJinLi = true
                        that.get_visitRegion()
                    } else {
                        that.getPersonal()
                    }
                },
                error: function (e) {
                    alert(e.responseText)
                }
            })
        }
    });
</script>
</body>
</html>